﻿@using VocaDb.Web.Helpers;
@using R = ViewRes.User;
@model VocaDb.Web.Models.Shared.PagingData<VocaDb.Model.DataContracts.Users.UserContract>

<div class="pager">
@Html.Pager(Model.Items.PageSize, Model.Items.PageNumber, Model.Items.TotalItemCount, new AjaxOptions { HttpMethod = "Post", InsertionMode = System.Web.Mvc.Ajax.InsertionMode.Replace, UpdateTargetId = Model.ContainerName }).Options(o => o.Action(Model.Action).AddRouteValue("id", Model.Id).AddRouteValue("totalCount", Model.Items.TotalItemCount))
</div>

<table class="table table-striped">
	<thead>
		<tr>
			<th colspan="2">
				@Html.ActionLink(R.DetailsStrings.UserName, "Index", new { GroupId = Model.Items.GroupId, sort = VocaDb.Model.Service.UserSortRule.Name })
			</th>
			<th>
				@Html.ActionLink(R.DetailsStrings.MemberSince, "Index", new { GroupId = Model.GroupId, sort = VocaDb.Model.Service.UserSortRule.RegisterDate })
			</th>
			<th>
				@Html.ActionLink(R.DetailsStrings.UserGroup, "Index", new { GroupId = Model.GroupId, sort = VocaDb.Model.Service.UserSortRule.Group })
			</th>
			<th></th>
		</tr>
	</thead>
	<tbody>
	@foreach (var user in Model.Users) {
		<tr>
			<td>
				<a href="@Url.Action("Details", new { id = user.Id })">
					@Html.ProfileIcon(user)					
				</a>
			</td>
			<td>
				@Html.ActionLink(user.Name, "Details", new { id = user.Id })
			</td>
			<td>
				@user.CreateDate
			</td>
			<td>
				@Translate.UserGroups[user.GroupId]
			</td>
			<td>
				@if (Login.Manager.HasPermission(VocaDb.Model.Domain.Security.PermissionToken.ManageUserPermissions)) {
					<text>&nbsp;</text>
					@Html.ActionLink(ViewRes.SharedStrings.Edit, "Edit", new { id = user.Id }, new { @class = "textLink editLink" });	
				}
			</td>
		</tr>
	}
	</tbody>
</table>